﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>代理商添加</title>

	<link rel="stylesheet" href="/scriptZIP/layui.min.css">
	<link rel="stylesheet" href="css/common2.css">
	<link rel="stylesheet" href="css/layui.css" />
	
	<link rel="stylesheet" href="/scriptZIP/vue-select.min.css">
	<style>
		.layui-row {
			margin-top: 50px;
		}
	</style>
</head>

<body>
	
	<form class="layui-form" id="vue-root">
		<div class="layui-row" ref="veefrom">
			<div class="layui-col-md6 layui-col-md-offset3">
				<div class="layui-form-item">
					<label class="layui-form-label">代理商</label>
					<div class="layui-input-block">
						<input name="agent" v-validate="'required|min:2'" autocomplete="off" placeholder="请输入代理商"
							class="layui-input name" v-model="item.name" data-vv-as="名称">
						<div class="checkout_state" v-text="err('agent')"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">联系人</label>
					<div class="layui-input-block">
						<input name="linkman" autocomplete="off" placeholder="请输入联系人" class="layui-input telname"
							v-model="item.linkman" data-vv-as="联系人">
						<div class="checkout_state" v-text="err('linkman')"></div>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">联系方式</label>
					<div class="layui-input-block">
						<input name="phone" autocomplete="off" placeholder="请输入联系方式" class="layui-input tel"
							v-model="item.contactInfo" data-vv-as="联系方式">
						<div class="checkout_state"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-block">
						<input name="username" v-validate="'required'" autocomplete="off" placeholder="请输入用户名"
							class="layui-input username" v-model="item.username" data-vv-as="用户名">
						<div class="checkout_state" v-text="err('username')"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-block">
						<input autocomplete="off" placeholder="请输入密码" class="layui-input password"
							v-model="item.password" data-vv-as="密码">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">限制公众号数量</label>
					<div class="layui-input-block">
						<input autocomplete="off" placeholder="公众号个数" class="layui-input" v-model="item.platformLimit"
							type="number">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">限制每个公众号学校数量</label>
					<div class="layui-input-block">
						<input autocomplete="off" placeholder="每个公众号学校数量" class="layui-input" v-model="item.schoolLimit"
							type="number">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">子代理商</label>
					<div class="layui-input-block">
						<v-select multiple placeholder="请选择代理商" label="name" :options="agents" :reduce="item=>item.id"
							v-model="item.subAgentIds"></v-select>
					</div>
				</div>


				<div class="layui-form-item">
					<div class="layui-input-block">
						<input type="button" class="offer" value="立即提交" @click="submit">
						<div class="return" onclick="history.back()" style="margin-top: 0 !important;">取消</div>
					</div>
				</div>
			</div>
		</div>
	</form>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	
	
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/scriptZIP/vue-select.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/item.js"></script>

	<script>
		Vue.component('v-select', VueSelect.VueSelect);
		var app = new Vue(merge({
			data: {
				url: '/pc/agent',
				item: {
					subAgentIds: []
				},
				agents: [],
			},
			created: function () {
				axios.get('/pc/agent/all').then(function (res) {
					this.agents = res.data;
					this.item.agentIds = this.agents.map(function (it) {
						return it.id;
					});
				}.bind(this));
				this.init();
			},
			methods: {

			}
		}));
	</script>
</body>

</html>